<@t.html>
<link rel="stylesheet" type="text/css" href="public/admin/datagrid/css/datagrid.css" media="screen" />
<script src="public/admin/datagrid/datagrid.js" type="text/javascript"></script>  
<body>
	<div class="cms-container">
		<div class="contentList">
			<div class="toolbar">
					  <@t.btn_b name="新建" icon="plus" onclick="add_new('${type}','${category}')"/>
	  	       		  <@t.btn_b name="删除" icon="trash" onclick="batchDeleteFun('admin/content/delete');" />
	  	       		  <@t.btn_b name="刷新" icon="refresh" onclick="window.location.reload();" />
			</div>
			<div class="panel">
					<!--search area-->
					
			</div>
			<div class="panel">
				<div class="datagrid-container">
			       <table class="datagridHead">
			                <tr>
			                    <td style="padding:0 7px;"><label class="checkAll"><input id="contentlist_AllCheck" type="checkbox" value="" onclick="selectAll(this)">全选</label> </td>
			                </tr>
					</table>
				   <table class="dataList">
				   		<#list page.list as a>
			              	<tr onclick="checkCoreContent('${a.id}',false);">
			              		<td class="dataRow">
					              	<table>
					              		<tr>
						                      	<td width="20">
						                      		<input name='SelectedID' id="select_${a.id}" value="${a.id}" type="checkbox">
						                      		<span class="seq">${a.seq}</span>
						                      	</td>
						                        <td width="66" align="center"><img class="previewImg" src="http://demo.zving.com/demo/preview/News/upload/resources/image/2013/07/02/77c493ec14246d748db3ee8fce0092db.jpg?1418908801781"></td>
												<td style="padding:0px 6px;"><div class="articleTitle" title="${a.title}">${a.title}</div>
													<div class="articleListInfo"><span class="dateTime">${a.created}</span>
														 <span class="state">${a.state}</span>
														 <span class="creator">${a.editor}</span>
														 <span class="flags"><i class="icon hot"></i><i class="icon pic"></i><i class="icon up"></i></span>
													</div>
												</td>
										</tr>
									</table>
								</td>		
			              	</tr>
			             </#list>
					</table>
					<table class="datagridFooter">
						<!--pager-->
			             <tr>
			             	<td>
			             		<div class="pageBar">
			             			<div class="pagerInfo">共3条记录</div>
			             			<div class="pagerController">
			             				<span class="first"><a href="javascript:void(0);" onclick="">第一页</a></span><span class="previous">
			             				<a href="javascript:void(0);" onclick="">上一页</a></span><span class="next">
			             				<a href="javascript:void(0);" onclick="">下一页</a></span><span class="last"><a href="javascript:void(0);" onclick="">最末页</a></span>
			             			</div>
			             		</div>
			             	</td>
			             </tr>
					</table>
				</div>
			</div>
	  		<!--pager-->
  			<@t.back_pager objCount=page.totalRow pageSize=page.pageSize pageNum=page.pageNumber pageCount=page.totalPage></@t.back_pager>
		</div>

		<!--show -->
		<div class="contentDetail">
			<div class="panel" id="btnTooler">
				      <@t.btn_b name="新建" icon="plus" onclick="add_new('${type}','${category}')"/>
	  	       		  <@t.btn_b name="快速编辑" icon="refresh" id="quickEditBtn"/>
	  	       		  <@t.btn_b name="编辑" icon="edit" id="fullScreenEdit"/>
	  	       		  <@t.btn_b name="保存" icon="save" id="quickSave" style="display:none;"/>
	  	       		  <@t.btn_b name="编辑" icon="trash" onclick="batchDeleteFun('admin/content/delete');" />
	  	       		  <@t.btn_b name="置顶" icon="refresh" onclick="window.location.reload();" />
	  	       		  <@t.btn_b name="相关内容" icon="refresh" onclick="window.location.reload();" />
	  	       		  <@t.btn_b name="发表到微博" icon="refresh" onclick="window.location.reload();" />	
			</div>
			<div class="panel">
				<input id="id" name="id" type="hidden" value="">
				<input id="category_id"   name="category_id" type="hidden" value="">
				<div class="coreTitle" id="coreTitle"><b>标题:</b><span class="titleContent" id="titleContent">中海油在渤海发现大型油田</span>
					<input type="text" id="title_input" style="display: none; line-height: 20px;height: 20px;width: 350px;background: #F7FCFF;border: 1px solid #efefef;" name="title">
				</div>
				<div class="coreContent" id="coreContent">
					
				</div>
				<textarea id="coreContent_textarea" style="display: none;">
				</textarea>
			</div>
		</div>
		<div class="clear"></div>
	</div>
<script>
function add_new(type,category,id){
	var url='admin/content/toAdd?category='+category;
	if(typeof(id)!='undefined'){
		url+='&id='+id;
	}
	if(type==2){
		parent.messager.iframe(url,"新建",800,600);
	}else if(type==1){
		window.location.href=url;
	}
}
var timer;
function checkCoreContent(id,mulit){
	if(!mulit)$(":checkbox[name='SelectedID']").attr('checked',false);
	$('#select_'+id).attr('checked',true);
	clearTimeout(timer);
	timer=setTimeout(function(){
		$.axsf("admin/content/quickView",'id='+id,function(d){
		if(d.code==200){
			var content=$.parseJSON(d.message);
			$('#id').val(content.id);
			$('#category_id').val(content.category_id);
			$('#titleContent').html(content.title);
			$('#coreContent').html(content.text);
		}
	});
	},500);
}
var editor_height=$('html').height()-$('#btnTooler').outerHeight()-$('#coreTitle').outerHeight();
function initHight(){
	$('#fullScreenEdit').click(function(){
		var id=$('#id').val();
		window.location.href="admin/content/toAdd?id="+id;
	});
    $('#coreContent').css('overflow-X','hidden').css('overflow-Y','auto');
	$('#coreContent').height(editor_height-100);
	alert($('body').height());
	$('.contentList').height($('body').height());
}

$(function(){
        initHight();
		$('#quickEditBtn').click(function(){
			$(this).hide();
			$('#quickSave').show();
			var title=$('#titleContent').html();
			var content=$('#coreContent').html();
            $('#coreContent').css("display","none");
            $('#titleContent').css("display","none");
			$('#coreContent_textarea').css('display','block').val(content);
            $('#title_input').css('display','inline-block').val(title);
            var quickEditor=UE.getEditor('coreContent_textarea', {
                initialFrameWidth:"100%"
            })
            quickEditor.addListener( 'ready', function( editor ) {
                quickEditor.setContent(content);
                quickEditor.setHeight(editor_height-200);
            } );
		});
    	$('#quickSave').click(function(){
            $(this).hide();
            $('#quickEditBtn').show();
            var quickEditor=UE.getEditor('coreContent_textarea');
            var title=$('#title_input').val();
            var content=quickEditor.getContent();
            quickEditor.destroy();
            $('#coreContent_textarea').css('display','none');
            $('#title_input').css('display','none');
            $('#coreContent').html(content).css("display","block");
            $('#titleContent').html(title).css("display","inline");

    	});

});
</script>
	<script type="text/javascript" src="public/common/ueditor/ueditor.config.js"></script>
	<script type="text/javascript" src="public/common/ueditor/ueditor.all.min.js"></script>

</@t.html>